package cn.liu.jetpack_demo.routes

import android.util.Log
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.NavHostController
import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.navArgument
import cn.liu.jetpack_demo.models.BottomBar
import cn.liu.jetpack_demo.pages.DetailPage
import cn.liu.jetpack_demo.pages.HomePage
import cn.liu.jetpack_demo.pages.ProfilePage
import cn.liu.jetpack_demo.pages.SettingsPage
import cn.liu.jetpack_demo.pages.StickyHeaderScreen
import cn.liu.jetpack_demo.pages.user.list.UserListPage

@ExperimentalFoundationApi
@ExperimentalMaterial3Api
@Composable
fun BottomNavGraph(navController: NavHostController, modifier: Modifier) {
  NavHost(
    modifier = modifier,
    navController = navController,
    startDestination = BottomBar.Home.route
  ) {
    composable(route = BottomBar.Home.route) {
      HomePage(navController = navController)
    }
    composable(route = BottomBar.Profile.route) {
      ProfilePage(navController = navController)
    }
    composable(route = BottomBar.Setting.route) {
      SettingsPage(navController = navController)
    }

    composable(
      route = Screen.Detail.route,
      arguments = listOf(navArgument(DEFAULT_ARGUMENT_KEY) {
        type = NavType.IntType
      },
        navArgument(DEFAULT_ARGUMENT_KEY2) {
          type = NavType.StringType
        }
      )
    ) {
      Log.d("Args id::", it.arguments?.getInt(DEFAULT_ARGUMENT_KEY).toString())
      Log.d("Args name::", it.arguments?.getString(DEFAULT_ARGUMENT_KEY2).toString())
      DetailPage(navController = navController)
    }
    composable(route = Screen.UserList.route) {
      UserListPage(navController = navController)
    }
    composable(route = Screen.StickyHeader.route) {
      StickyHeaderScreen(navController = navController)
    }
    passportNavGraph(navController = navController)
  }
}